/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hhf.worldzones.daos;

import hhf.worldzones.entities.City;
import hhf.worldzones.entities.Region;
import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

/**
 *
 * @author François
 */
@Stateless
public class CityDAO extends ZoneDAO<City> {
	public CityDAO() {
		super(City.class);
	}

	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
	@Asynchronous
	public void createCity(String cityCode, String label, Integer latitude, Integer longitude, String postalCode, Region region) {
		if (!contains(cityCode)) {
			City city = new City();
			city.setCode(cityCode);
			city.setLabel(label);
			city.setLatitude(latitude);
			city.setLongitude(longitude);
			city.setPostalCode(postalCode);
			city.setRegion(region);
			persist(city);
		}
	}
}
